import cv2
import os
import numpy as np

srcImgPath = os.getcwd().strip('code\ch1') + '\pic\DIP3E_Original_Images_CH02\Fig0236(a)(letter_T).tif'
srcImg = cv2.imread(srcImgPath)
cv2.imshow("src", srcImg)

rows, cols = srcImg.shape[:2]
roateM = cv2.getRotationMatrix2D((cols/2, rows/2), -21, 1)
destImg = cv2.warpAffine(srcImg, roateM, (cols, rows), flags=cv2.INTER_NEAREST)
cv2.imshow("roated", destImg)

cv2.imwrite("src.bmp", srcImg)
cv2.imwrite("roate.bmp", destImg)
cv2.waitKey(0)